﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BW.EatRabbit.Infrastructure.Interfaces
{

    /// <summary>
    /// 仓储接口层
    /// </summary>
    /// <typeparam name="T">实体</typeparam>
    public interface IBaseRepository<T> where T : class
    {
        
        /// <summary>
        /// 获取全部信息
        /// </summary>
        /// <returns>返回受影响的行数</returns>
        IQueryable<T> GetAll();
        /// <summary>
        /// 新增实体
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns>返回受影响的行数</returns>
        int AddEntity(T entity);
        /// <summary>
        /// 根据ID获取实体
        /// </summary>
        /// <param name="id">主键ID</param>
        /// <returns>返回实体</returns>
        T GetEntity(int id);
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns>返回受影响的行数</returns>
        int UpdateEntity(T entity);

        int UpdateRange(IQueryable<T> entity);

    }
}
